package com.example.demo2.service;

import com.example.demo2.bean.YourBean;
import com.example.demo2.dao.YourBeanDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class YourBeanService {

    @Autowired
    YourBeanDao dao;

    public List<YourBean> list(){
        List<YourBean> all = dao.findAll();
        return all;
    }

    public YourBean login(YourBean yourBean) {
        YourBean yourBean1 = dao.findOne(Example.of(yourBean)).orElse(null);
        return yourBean1;
    }

    public YourBean register(YourBean yourBean) {
        YourBean save = dao.save(yourBean);
        return save;
    }

    public YourBean findone(YourBean yourBean) {
        YourBean yourBean1 = dao.findOne(Example.of(yourBean)).orElse(null);
        return yourBean1;
    }

    public void deleteById(Integer id) {
        dao.deleteById(id);
    }

    public YourBean update(YourBean yourBean) {
        YourBean save = dao.save(yourBean);
        return save;
    }

    public YourBean addone(YourBean yourBean) {
        YourBean save = dao.save(yourBean);
        return save;
    }
}
